package org.ohos.rajawali3d.examples.examples.materials.materials;

import ohos.global.resource.RawFileEntry;
import ohos.global.resource.ResourceManager;
import opengl.platform.ohos.GLES20;
import org.rajawali3d.materials.shaders.FragmentShader;
import org.rajawali3d.util.RawShaderLoader;

public class CustomRawFragmentShader extends FragmentShader {
    private int muTextureInfluenceHandle;

    public CustomRawFragmentShader() {
        super();
        mNeedsBuild = false;
        initialize();
    }

    @Override
    public void initialize() {
        ResourceManager resManager = RawShaderLoader.mContext.get().getResourceManager();
        RawFileEntry rawFileEntry = resManager.getRawFileEntry("resources/rawfile/custom_frag_shader.glsl");
        mShaderString = RawShaderLoader.fetch(rawFileEntry);
    }

    @Override
    public void main() {

    }

    @Override
    public void setLocations(final int programHandle) {
        super.setLocations(programHandle);
        muTextureInfluenceHandle = getUniformLocation(programHandle, "uInfluencemyTex");
    }

    @Override
    public void applyParams() {
        super.applyParams();
        GLES20.glUniform1f(muTextureInfluenceHandle, .5f);
    }
}
